<%--
  Created by IntelliJ IDEA.
  User: 邹敦宇
  Date: 2021/3/8
  Time: 10:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>爱购登录页面</title>
    <%
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
    %>
    <base href="<%=basePath%>">
    <link rel="icon" type="image/x-icon" href="img/title-icon.jpg"/>
    <link rel="stylesheet" href="css/reset.css" />
    <link rel="stylesheet" href="css/footer.css" />
    <link rel="stylesheet" href="css/login.css" />
</head>
<body>
<!--登录/注册的头部-->
<div class="lr-top w1230">
    <a href="index.html"><img src="img/logo.png" width="150px" height="60px"/></a>
    <div class="top-link">
        <a href="#"class="top-link1"></a>
        <a href="#" class="top-link2"></a>
        <a href="#" class="top-link3"></a>
    </div>
</div>
<!--登录/注册的中部-->
<div class="lr-main">
    <div class="w1230">
        <div class="reg-div">
            <h3 class="login-title">登录爱购</h3>
            <p class="go-reg">还没有爱购账号？<a href="register.html">在此注册</a></p>
            <form action="" method="" id="form">
                <p><span class="icon-account"></span><input type="text" name="username" placeholder="请输入已注册的账号"/></p>
                <p><span class="icon-pwd"></span><input type="password" name="password" placeholder="请输入密码"/></p>
                <p class="clear-float"><input type="text" placeholder="验证码" name="vercode" class="code"/><img src="/eshop/captcha" width="110px" height="42px" id="vcode" class="code-img"/></p>
                <p><input type="checkbox" name="chk" class="chk-login"/><span>7天免登录</span></p>
                <input type="button" value="登录" class="sum-btn" />
            </form>
        </div>
    </div>
</div>
<!--登录/注册的底部-->
<div class="lr-footer footer">
    <p class="w1230">
        <a href="#">关于爱购</a>
        <a href="#">合作伙伴</a>
        <a href="#">营销中心</a>
        <a href="#">廉正举报</a>
        <a href="#">联系客服</a>
        <a href="#">开发平台</a>
        <a href="#">诚征英才</a>
        <a href="#">联系我们</a>
        <a href="#">网站地图</a>
        <a href="#">知识产权</a><span>|</span>
        <span>&copy;2018-2020 igo.com 版权所有</span>
    </p>
</div>

<script src="static/js/jquery-3.5.1.min.js"></script>
<script>
    $(function () {
        $(".sum-btn").click(function () {
            $.ajax({
                type:"post",
                url:"/eshop/Users.do?m=login",
                data:{
                    username:$("input[name='username']").val(),
                    password:$("input[name='password']").val(),
                    vercode:$("input[name='vercode']").val(),
                    chk:$("input[name='chk']")[0].checked?'true':'false'
                },
                dataType:'json',
                success:function (data) {
                    if (data=="前台用户"){
                        alert("登录成功")
                        window.location="/eshop/reception/index.jsp"
                    }else if(data="验证码错误"){
                        alert("验证码错误")
                        $("#vcode").attr("src","/eshop/captcha?"+Math.random())
                    }else {
                        if (data=="后台用户"){
                            alert("后台用户，请去后台登录")
                        }
                    }
                    console.log(data);
                }
            })
        })

        $("#vcode").click(function () {
            $("#vcode").attr("src","/eshop/captcha?"+Math.random())
        })

    })
</script>
</body>
</html>
